//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//     Filename: XMLDoc.h                                                   //
//  Create date: April 02, 2004                                             //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//  Description: This file describes the XMLDoc class, which is a wrapper   //
//                 class for the Microsoft IID_IXMLDOMDocument2 interface.  //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////
//       Copyright (c) 2004 - Realtime Gaming.  All rights reserved.        //
//////////////////////////////////////////////////////////////////////////////

#ifndef __XMLDOC__
#define __XMLDOC__

#include <windows.h>
#include <objbase.h>
#include "COMDEF.H"
#include "lib.h"
#include "msxml2.h"
#include "TCHAR.h"
#include "card.h"

//////////////////////////////////////////////////////////////////////////////
// XMLDoc Class
//////////////////////////////////////////////////////////////////////////////
class XMLDoc
{
public:
    XMLDoc();
    ~XMLDoc();

    bool8 Create();

	bool8 Save( const String& sPath );

    bool8 LoadXML( uint8* pBuffer );
	bool8 SendXML( uint8* pBuffer, uint32 nBuffSize );

    bool8 GetSingleNodeText ( const String& sQuery, String& sBuffer );
	bool8 GetSingleNodeByte ( const String& sQuery, uint8& nByteVal );
	bool8 GetSingleNodeLong ( const String& sQuery, uint32& nLongVal );
	bool8 GetSingleNodeShort( const String& sQuery, uint16& nShortVal );
	bool8 GetSingleNodeBool ( const String& sQuery, bool8& bVal, bool8 bDefaultVal = false );

	bool8 AddProcessingInstruction( const String& sInstruction );

	bool8 StartNew();

	bool8 CreateRootNode( const String& sName );

	bool8 AddRootChildNode( const String& sName );
	bool8 AddRootChildNode( const String& sName, const String& sValue );
	bool8 AddRootChildNode( const String& sName, uint32 nValue );
	bool8 AddRootChildNode( const String& sName, bool8 bValue );
	bool8 AddRootChildNode( const String& sName, const Card& c );

	bool8 AddChildNode( const String& sParentQuery, const String& sName );
	bool8 AddChildNode( const String& sParentQuery, const String& sName, const String& sValue );
	bool8 AddChildNode( const String& sParentQuery, const String& sName, uint32 nValue );
	bool8 AddChildNode( const String& sParentQuery, const String& sName, bool8 bValue );
	bool8 AddChildNode( const String& sParentQuery, const String& sName, const Card& c );
	
	bool8 ReplaceRootChildNode( const String& sName, const String& sValue );
	bool8 ReplaceRootChildNode( const String& sName, uint32 nValue );
	bool8 ReplaceRootChildNode( const String& sName, bool8 bValue );
	bool8 ReplaceRootChildNode( const String& sName, const Card& c );

	bool8 RemoveRootChildNode( const String& sName );

protected:
    IXMLDOMDocument2* m_pXMLDoc;
	IXMLDOMElement*   m_pRoot;
};

#endif //#ifndef __XMLDOC__